package com.example.oasystem.dao.file;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.oasystem.entity.file.AoaFileList;
import com.example.oasystem.entity.file.AoaFilePath;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AoaFilePathDao extends BaseMapper<AoaFilePath> {

    List<AoaFilePath> selectmcpaths(Long pathId);

    List<AoaFilePath> selectAllParentpaths(Long pathId);

    List<AoaFilePath> selectAllChildPaths(Long pathId);

    void save(AoaFilePath filepath);

    //通过parid pname puserid查找filepath
    @Select("select * from aoa_file_path where parent_id=#{parentId} and path_name=#{pathName} and path_user_id=#{pathUserId}")
    AoaFilePath findfPath(AoaFilePath copypath);

    //通过parentid获取路径列表
    List<AoaFilePath> findpathByParent(@Param("parentId") Long parentId,@Param("userid") Long userid);
    //通过用户名获取文件路径
    AoaFilePath findFileByUserName(@Param("userName") String userName);
    List<AoaFileList> findByFileNameLike(@Param("userid") Long userid, @Param("contenttype") String contenttype, @Param("likefilename") String likefilename);

    //垃圾箱查找
    @Select("select * from aoa_file_path where path_user_id=#{userid} and path_name like #{likefilename} and path_istrash=1")
    List<AoaFilePath> findByPathUserIdAndPathIstrashAndPathNameLikeAndParentIdNot(@Param("userid") Long userid,@Param("likefilename") String likefilename);
    @Select("select * from aoa_file_list where file_user_id=#{userid} and file_name like #{likefilename} and file_istrash=1")
    List<AoaFileList> findByUserAndFileIstrashAndContentTypeLikeAndFileNameLike(@Param("userid") Long userid,@Param("likefilename") String likefilename);

    //分享查找
    @Select("select * from aoa_file_list where file_name like #{likefilename} and file_isshare = 1")
    List<AoaFileList> findByFileIsshareAndFileNameLike(@Param("likefilename") String likefilename);
    @Select("select * from aoa_file_path where path_user_id=#{userid} and path_name like #{likefilename} ")
    List<AoaFilePath> findByPathUserIdAndPathIstrashAndPathNameLikeAndParentIdNota(@Param("userid") Long userid,@Param("likefilename") String likefilename);
    @Select("select * from aoa_file_list where file_user_id=#{userid} and file_name like #{likefilename}")
    List<AoaFileList> findByUserAndFileIstrashAndFileNameLike(@Param("userid") Long userid,@Param("likefilename") String likefilename);


}